package com.pie4cloud.pie.job.biz.gather.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pie4cloud.pie.common.core.util.R;
import com.pie4cloud.pie.common.log.annotation.SysLog;
import com.pie4cloud.pie.job.api.entity.CheckInfo;
import com.pie4cloud.pie.job.biz.gather.service.CheckInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author feilei
 * @date 2022-01-10 00:54:34
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/checkinfo" )
@Api(value = "checkinfo", tags = "管理")
public class CheckInfoController {

    private final CheckInfoService checkInfoService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param checkInfo 
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('gather_checkinfo_get')" )
    public R getCheckInfoPage(Page page, CheckInfo checkInfo) {
        return R.ok(checkInfoService.page(page, Wrappers.query(checkInfo)));
    }


    /**
     * 通过id查询
     * @param checkId id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{checkId}" )
    @PreAuthorize("@pms.hasPermission('gather_checkinfo_get')" )
    public R getById(@PathVariable("checkId" ) Long checkId) {
        return R.ok(checkInfoService.getById(checkId));
    }

    /**
     * 新增
     * @param checkInfo 
     * @return R
     */
    @ApiOperation(value = "新增", notes = "新增")
    @SysLog("新增" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('gather_checkinfo_add')" )
    public R save(@RequestBody CheckInfo checkInfo) {
        return R.ok(checkInfoService.save(checkInfo));
    }

    /**
     * 修改
     * @param checkInfo 
     * @return R
     */
    @ApiOperation(value = "修改", notes = "修改")
    @SysLog("修改" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('gather_checkinfo_edit')" )
    public R updateById(@RequestBody CheckInfo checkInfo) {
        return R.ok(checkInfoService.updateById(checkInfo));
    }

    /**
     * 通过id删除
     * @param checkId id
     * @return R
     */
    @ApiOperation(value = "通过id删除", notes = "通过id删除")
    @SysLog("通过id删除" )
    @DeleteMapping("/{checkId}" )
    @PreAuthorize("@pms.hasPermission('gather_checkinfo_del')" )
    public R removeById(@PathVariable Long checkId) {
        return R.ok(checkInfoService.removeById(checkId));
    }

}
